package com.framework;

import com.framework.myBatis.QueryFilter;
import org.mybatis.spring.SqlSessionTemplate;
import org.slf4j.Logger;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.HashMap;
import java.util.List;

public  abstract class BaseServiceImpl<T, K extends Serializable> implements BaseService<T, K> {

    @Resource
    protected SqlSessionTemplate sqlSessionTemplate;
    protected Logger logger;

    public SqlSessionTemplate getSqlSessionTemplate(){
        return this.sqlSessionTemplate;
    }


    public  abstract String getNamespace();

    private   String getStatmementKey(String StatmementKey){
        return getNamespace()+"."+StatmementKey;
    }


    @Override
    public Result deleteByPrimaryKey(T id) {
//        HashMap param = new HashMap(  );
//        param.put( "id" ,id);
//        int  deleteByPrimaryKey = sqlSessionTemplate.delete( getStatmementKey( "deleteByPrimaryKey" ), param );
//        Result result = new Result();
//        result.setReturnObj( deleteByPrimaryKey );
//        return result;
        return null;
    }

    @Override
    public Result insert(K record) {
//        int insert = sqlSessionTemplate.insert( getStatmementKey( "insert" ), record );
//        Result result = new Result();
//        result.setReturnObj( record );
//        return result;
        return null;
    }

    @Override
    public Result insertSelective(K record) {
//        int insert = sqlSessionTemplate.insert( getStatmementKey( "insertSelective" ), record );
//        Result result = new Result();
//        result.setReturnObj( record );
//        return result;
        return null;
    }

    @Override
    public K selectByPrimaryKey(T id) {
//        HashMap param = new HashMap(  );
//        param.put( "id" ,id);
//        Object selectByPrimaryKey = sqlSessionTemplate.selectOne( getStatmementKey( "selectByPrimaryKey" ), param );
//        return (K)selectByPrimaryKey;
        return null;
    }

    @Override
    public List<K> selectList() {
//        List<K> selectList = sqlSessionTemplate.selectList( getStatmementKey( "selectList" ) );
//        return selectList;

        return null;
    }

    @Override
    public Result updateByPrimaryKeySelective(K record) {
        return null;
    }

    @Override
    public Result updateByPrimaryKey(K record) {
        return null;
    }

    @Override
    public Result findOne(QueryFilter filter) {
        return null;
    }

    @Override
    public Result findList(QueryFilter filter) {
        return null;
    }

    @Override
    public Result findPager(QueryFilter filter) {
        return null;
    }

    @Override
    public Result delete(QueryFilter filter) {
        return null;
    }

    @Override
    public Result save(QueryFilter filter) {
        return null;
    }

    @Override
    public Result update(QueryFilter filter) {
        return null;
    }
}
